<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>体检记录管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					/* loading('正在提交，请稍等...');
					form.submit(); */
					postOrderDetil(form);
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			$("#height").blur(function(){
				var height = $("#height").val();
				var weight = $("#weight").val();
				if(height == "" || weight == ""){
					$("#status").val("");
					return;
				}
				height = height/100;
				var BMI = (weight/(height*height)).toFixed(1);
				if(BMI < 18.5){
					$("#status").val(BMI+"-"+"偏瘦");
				}else if(BMI >=18.5 && BMI <= 23.9){
					$("#status").val(BMI+"-"+"正常");
				}else if(BMI >=24 && BMI <= 27.9){
					$("#status").val(BMI+"-"+"超重");
				}else if(BMI >= 28){
					$("#status").val(BMI+"-"+"肥胖");
				}
			});
			$("#weight").blur(function(){
				var height = $("#height").val();
				var weight = $("#weight").val();
				if(height == "" || weight == ""){
					$("#status").val("");
					return;
				}
				height = height/100;
				var BMI = (weight/(height*height)).toFixed(1);
				if(BMI < 18.5){
					$("#status").val(BMI+"-"+"偏瘦");
				}else if(BMI >=18.5 && BMI <= 23.9){
					$("#status").val(BMI+"-"+"正常");
				}else if(BMI >=24 && BMI <= 27.9){
					$("#status").val(BMI+"-"+"超重");
				}else if(BMI >= 28){
					$("#status").val(BMI+"-"+"肥胖");
				}
			});
			$("#btnAddStudent").click(function(){
				var schoolCode = $("#schoolCodeId").val();
				if(schoolCode == ""){
					layer.alert('请先选择学校信息', {
				      skin: 'layui-layer-molv' //样式类名  自定义样式
				      ,closeBtn: 1    // 是否显示关闭按钮
				      ,anim: 1 //动画类型
				      ,btn: ['确认'] //按钮
				      ,icon: 6    // icon
				      ,offset: '0px'
				      ,yes:function(){
				    	  layer.closeAll();
				      }
				     ,btn2:function(){
				    }});
					return;
				}
				var url = "${ctx }/student/student/getList?schoolCode="+schoolCode;
				var height = window.screen.availHeight * 0.6;
				var width = window.screen.availWidth * 0.7;
				layer.open({
					type : 2,
					title : '学生信息',
					shadeClose : true,
					//skin : 'layui-layer-rim',
					shade : 0.8,
					resize : false,
					area : [ width + "px", height + "px" ],
					content : url
				});
			});
		});
		function postOrderDetil(form) {//表单保存时  将此方法中的数据尽行保存
			/* var weight = parseInt($("#weight").val());
			var vitalCapacity = parseInt($("#vitalCapacity").val());
			var s =  Math.round(vitalCapacity/weight)
			var gender = $("#gender").val();
			var status = $("#status").val("");
			$("#vitalCapacity").val(vitalCapacity+"-"+Math.round(vitalCapacity/weight)); */
			layer.confirm('确定保存？', {
				icon: 3, title:'提示',
				btn : [ '保存', '取消' ]
			//按钮
			}, function() {
				layer.load(2);
				loading('正在提交，请稍等...');
				form.submit();
			});
		}
		function getStuGrade(schCode){
			$("#schoolCode").val(schCode);
			var url = "${ctx}/sysschool/sysSchool/getSchCode";
			$.ajax({
				url :url,
				async: false,
				data :{"code":schCode},
				success : function(data){
					if(data != null){
						var strDate = data.physicalDate;
						$("#enrtYear").val(strDate.substring(0,10));
					}else{
					    $("#enrtYear").val("");
				    }
				}
			});
		}
		function addInfo(student){
			$("#childId").val(student.id);
			$("#stuName").val(student.stuName);
			$("#stuCode").val(student.stuCode);
			$("#stuGrade").val(student.stuGrade);
			$("#className").val(student.className);
			$("#classCode").val(student.classCode);
			$("#gender").val(student.gender);
			$("#nation").val(student.nation);
			$("#birthday").val(student.birthday);
		}
	</script>
	<style type="text/css">
		/* #nose::-webkit-input-placeholder { WebKit browsers 
		   color: #9ad4ff; 
		} 
		#nose:-moz-placeholder { Mozilla Firefox 4 to 18 
		   color: #9ad4ff; 
		} 
		#nose::-moz-placeholder {  Mozilla Firefox 19+  
		   color: #9ad4ff; 
		} 
		#nose:-ms-input-placeholder { Internet Explorer 10+ 
		   color: #9ad4ff; 
		} */
		#contentTable td ,#contentTable th{
			text-align: center;
			padding: 1px 10px;
		}
	</style>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/childtijianrecord/childTijianRecord/">体检记录列表</a></li>
		<li class="active"><a href="${ctx}/childtijianrecord/childTijianRecord/form?id=${childTijianRecord.id}">体检记录<shiro:hasPermission name="childtijianrecord:childTijianRecord:edit">${not empty childTijianRecord.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="childtijianrecord:childTijianRecord:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="childTijianRecord" action="${ctx}/childtijianrecord/childTijianRecord/save" method="post" class="form-horizontal" autocomplete="off">
		<form:hidden path="id"/>
		<form:hidden path="childId"/>
		<form:hidden path="classCode"/>
		<sys:message content="${message}"/>	
		<div class="row-fluid">
			<div class="control-group span6 minWidth" data-line="line1">
				<label class="control-label"><font color="red">*</font> 学校：</label>
				<div class="controls">
				    <sys:treeselect3 id="schoolCode" name="schoolCode" value="${childTijianRecord.schoolCode}" labelName="schoolName" labelValue="${childTijianRecord.schoolName}"
			         title="学校" url="/sysschool/sysSchool/schTreeData" cssClass="form:input-medium" layer = "true" notAllowSelectParent="true" notAllowSelectRoot="true" 
			         disabled="${empty childTijianRecord.id == true ? 'false' : 'disabled'}"/>
			         <c:if test="${empty childTijianRecord.id}">
			            <input id="btnAddStudent" class="btn btn-primary" type="button" value="查询学生"/>
			         </c:if>
				</div>
			</div>
			
			<div class="control-group span6 minWidth" data-line="line2">
				<label class="control-label"><font color="red">*</font> 姓名：</label>
				<div class="controls">
					<form:input type="text" path="student.stuName" id="stuName" class="span6" value="${childTijianRecord.student.stuName}" readonly="true"/>
				</div>
			</div>
	    </div>	
	    
	    <div class="row-fluid">
			<div class="control-group span6 minWidth" data-line="line1">
				<label class="control-label"><font color="red">*</font> 学号：</label>
				<div class="controls">
					<form:input type="text" path="student.stuCode" id="stuCode" class="span6" value="${childTijianRecord.student.stuCode}" readonly="true"/>
				</div>
			</div>
			
			<div class="control-group span6 minWidth" data-line="line2">
				<label class="control-label"><font color="red">*</font> 年級：</label>
				<div class="controls">
				    <c:if test="${empty childTijianRecord.id}">
					    <form:input type="text" path="student.stuGrade" id="stuGrade" class="span6" value="${childTijianRecord.student.stuGrade}" readonly="true"/>
				    </c:if>
				    <c:if test="${not empty childTijianRecord.id}">
					    <form:select path="student.stuGrade" class="span2 minWidth" disabled="true">
							<form:option value="" label="--请选择--"/>
							<form:options items="${fns:getDictList('stu_grade')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
						</form:select>
				    </c:if>
				</div>
			</div>
		</div>
		
		<div class="row-fluid">
			<div class="control-group span6 minWidth" data-line="line1">
				<label class="control-label"><font color="red">*</font> 班級：</label>
				<div class="controls">
					<form:input type="text" path="className" class="span6" value="${childTijianRecord.className}" readonly="true"/>
				</div>
			</div>
			
			<div class="control-group span6 minWidth" data-line="line2">
				<label class="control-label"><font color="red">*</font> 性別：</label>
				<div class="controls">
				    <c:if test="${empty childTijianRecord.id}">
					    <form:input type="text" path="student.gender" id="gender" class="span6" value="${childTijianRecord.student.gender}" readonly="true"/>
				    </c:if>
				    <c:if test="${not empty childTijianRecord.id}">
					    <form:select path="student.gender" class="span2 minWidth" disabled="true">
							<form:option value="" label="--请选择--"/>
							<form:options items="${fns:getDictList('sex')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
						</form:select>
				    </c:if>
				</div>
			</div>
		</div>
		
		<div class="row-fluid">
			<div class="control-group span6 minWidth" data-line="line1">
				<label class="control-label"><font color="red">*</font> 民族：</label>
				<div class="controls">
				    <c:if test="${empty childTijianRecord.id}">
					    <form:input type="text" path="student.nation" id="nation" class="span6" value="${childTijianRecord.student.nation}" readonly="true"/>
				    </c:if>
				    <c:if test="${not empty childTijianRecord.id}">
					    <form:select path="student.nation" class="span2 minWidth" disabled="true">
							<form:option value="" label="--请选择--"/>
							<form:options items="${fns:getDictList('nation')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
						</form:select>
				    </c:if>
				</div>
			</div>
			
			<div class="control-group span6 minWidth" data-line="line2">
				<label class="control-label"><font color="red">*</font> 出生日期：</label>
				<div class="controls">
					<input type="text" name="student.birthday" id="birthday" class="span6" value="<fmt:formatDate value="${childTijianRecord.student.birthday}" pattern="yyyy-MM-dd"/>" readonly="readonly"/>
				</div>
			</div>
		</div>
		
		<div class="row-fluid">
	        <div class="control-group span6 minWidth" data-line="line1">
				<label class="control-label"><font color="red">*</font> 身高（cm）：</label>
				<div class="controls">
					<form:input type="text" path="height" class="span6 required digits" value="${childTijianRecord.height}"/>
				</div>
			</div>
			
			<div class="control-group span6 minWidth" data-line="line2">
				<label class="control-label"><font color="red">*</font> 体重（KG）：</label>
				<div class="controls">
					<form:input type="text" path="weight" class="span6 required digits" value="${childTijianRecord.weight}"/>
				</div>
			</div>
		</div>
			
	    <div class="row-fluid">
	        <div class="control-group span6 minWidth" data-line="line1">
				<label class="control-label">发育及营养状况：</label>
				<div class="controls">
					<form:input type="text" path="status" class="span6" value="${childTijianRecord.status}" readonly="true"/>
				</div>
			</div>
			
			<div class="control-group span6 minWidth" data-line="line2">
				<label class="control-label">胸围（cm）：</label>
				<div class="controls">
					<form:input type="text" path="bust" class="span6" value="${childTijianRecord.bust}"/>
				</div>
			</div>
		</div>
		
		<div class="row-fluid">
	        <div class="control-group span6 minWidth" data-line="line1">
				<label class="control-label"><font color="red">*</font> 肺活量（ml）：</label>
				<div class="controls">
					<form:input type="text" path="vitalCapacity" class="span6 required digits" value="${childTijianRecord.vitalCapacity}"/>
				</div>
			</div>
			
			<div class="control-group span6 minWidth" data-line="line2">
				<label class="control-label"><font color="red">*</font> 血压（mmHg）：</label>
				<div class="controls">
					<form:input type="text" path="blood" class="span6 required" value="${childTijianRecord.blood}" placeholder="血压填写规范，如 120/80  高压在前低压在后"/>
				</div>
			</div>
		</div>
		
		<div class="row-fluid">
	        <div class="control-group span6 minWidth" data-line="line1">
				<label class="control-label"><font color="red">*</font> 脉搏（次/分）：</label>
				<div class="controls">
					<form:input type="text" path="pulse" class="span6 required digits" value="${childTijianRecord.pulse}"/>
				</div>
			</div>
			
		</div>
		
		<div class="row-fluid">
	        <div class="control-group span6 minWidth" data-line="line1">
				<label class="control-label"><font color="red">*</font> 左裸眼视力：</label>
				<div class="controls">
					<form:input type="text" path="realLeftEye" class="span6" value="${childTijianRecord.realLeftEye}" placeholder="5.0"/>
				</div>
			</div>
			
			<div class="control-group span6 minWidth" data-line="line2">
				<label class="control-label"><font color="red">*</font> 右裸眼视力：</label>
				<div class="controls">
					<form:input type="text" path="realRightEye" class="span6" value="${childTijianRecord.realRightEye}" placeholder="5.0"/>
				</div>
			</div>
		</div>
		
		<div class="row-fluid">
	        <div class="control-group span6 minWidth" data-line="line1">
				<label class="control-label">左矫正视力：</label>
				<div class="controls">
					<form:input type="text" path="correctLeftEye" class="span6" value="${childTijianRecord.correctLeftEye}" placeholder="5.0"/>
				</div>
			</div>
			
			<div class="control-group span6 minWidth" data-line="line2">
				<label class="control-label">右矫正视力：</label>
				<div class="controls">
					<form:input type="text" path="correctRightEye" class="span6" value="${childTijianRecord.correctRightEye}" placeholder="5.0"/>
				</div>
			</div>
		</div>
		
		<div class="row-fluid">
	        <div class="control-group span6 minWidth" data-line="line1">
				<label class="control-label">沙眼：</label>
				<div class="controls">
					<form:input type="text" path="trachoma" class="span6" value="${childTijianRecord.trachoma}" placeholder="无"/>
				</div>
			</div>
			
			<div class="control-group span6 minWidth" data-line="line2">
				<label class="control-label">色觉：</label>
				<div class="controls">
					<form:input type="text" path="colorsense" class="span6" value="${childTijianRecord.colorsense}" placeholder="正常"/>
				</div>
			</div>
		</div>
		
		<div class="row-fluid">
	        <div class="control-group span6 minWidth" data-line="line1">
				<label class="control-label">鼻病：</label>
				<div class="controls">
					<form:input type="text" path="nose" class="span6" value="${childTijianRecord.nose}" placeholder="无"/>
				</div>
			</div>
			
			<div class="control-group span6 minWidth" data-line="line2">
				<label class="control-label">心脏：</label>
				<div class="controls">
					<form:input type="text" path ="heart" class="span6" value="${childTijianRecord.heart}" placeholder="正常"/>
				</div>
			</div>
		</div>
		
		<div class="row-fluid">
			<div class="control-group span6 minWidth" data-line="line1">
				<label class="control-label">左上口腔：</label>
				<div class="controls">
					<form:input type="text" path="leftUpperMouth" class="span6" value="${childTijianRecord.leftUpperMouth}" placeholder="无"/>
				</div>
			</div>
			
	        <div class="control-group span6 minWidth" data-line="line2">
				<label class="control-label">右上口腔：</label>
				<div class="controls">
					<form:input type="text" path="rightUpperMouth" class="span6" value="${childTijianRecord.rightUpperMouth}" placeholder="无"/>
				</div>
			</div>
		</div>
		
		<div class="row-fluid">
			<div class="control-group span6 minWidth" data-line="line1">
				<label class="control-label">左下口腔：</label>
				<div class="controls">
					<form:input type="text" path="leftLowerMouth" class="span6" value="${childTijianRecord.leftLowerMouth}" placeholder="无"/>
				</div>
			</div>
			
	        <div class="control-group span6 minWidth" data-line="line2">
				<label class="control-label">右下口腔：</label>
				<div class="controls">
					<form:input type="text" path="rightLowerMouth" class="span6" value="${childTijianRecord.rightLowerMouth}" placeholder="无"/>
				</div>
			</div>
		</div>
		
		<div class="row-fluid">
	        <div class="control-group span6 minWidth" data-line="line1">
				<label class="control-label">肺：</label>
				<div class="controls">
					<form:input type="text" path="luny" class="span6" value="${childTijianRecord.luny}" placeholder="正常"/>
				</div>
			</div>
			
			<div class="control-group span6 minWidth" data-line="line2">
				<label class="control-label">肝,脾：</label>
				<div class="controls">
					<form:input type="text" path="liver" class="span6" value="${childTijianRecord.liver}" placeholder="未触及肿大"/>
				</div>
			</div>
		</div>
		
		<div class="row-fluid">
	        <div class="control-group span6 minWidth" data-line="line1">
				<label class="control-label">胃肠：</label>
				<div class="controls">
					<form:input type="text" path="stomach" class="span6" value="${childTijianRecord.stomach}" placeholder="正常"/>
				</div>
			</div>
			
			<div class="control-group span6 minWidth" data-line="line2">
				<label class="control-label">脊柱：</label>
				<div class="controls">
					<form:input type="text" path="spine" class="span6" value="${childTijianRecord.spine}" placeholder="正常"/>
				</div>
			</div>
		</div>
		
		<div class="row-fluid">
	        <div class="control-group span6 minWidth" data-line="line1">
				<label class="control-label">四肢：</label>
				<div class="controls">
					<form:input type="text" path="limb" class="span6" value="${childTijianRecord.limb}" placeholder="正常"/>
				</div>
			</div>
			
			<div class="control-group span6 minWidth" data-line="line2">
				<label class="control-label">平足：</label>
				<div class="controls">
					<form:input type="text" path="foot" class="span6" value="${childTijianRecord.foot}" placeholder="无"/>
				</div>
			</div>
		</div>
		
		<div class="row-fluid">
	        <div class="control-group span6 minWidth" data-line="line1">
				<label class="control-label">皮肤：</label>
				<div class="controls">
					<form:input type="text" path="skin" class="span6" value="${childTijianRecord.skin}" placeholder="未见异常"/>
				</div>
			</div>
			
			<div class="control-group span6 minWidth" data-line="line2">
				<label class="control-label">传染病：</label>
				<div class="controls">
					<form:input type="text" path="contagion" class="span6" value="${childTijianRecord.contagion}" placeholder="无"/>
				</div>
			</div>
		</div>
		
		<div class="row-fluid">
	        <div class="control-group span6 minWidth" data-line="line1">
				<label class="control-label">胸透：</label>
				<div class="controls">
					<form:input type="text" path="chestXray" class="span6" value="${childTijianRecord.chestXray}" placeholder="未检"/>
				</div>
			</div>
			
			<div class="control-group span6 minWidth" data-line="line2">
				<label class="control-label">淋巴结：</label>
				<div class="controls">
					<form:input type="text" path="lymphGland" class="span6" value="${childTijianRecord.lymphGland}" placeholder="正常"/>
				</div>
			</div>
		</div>
		
		<div class="row-fluid">
		    <div class="control-group span6 minWidth" data-line="line1">
				<label class="control-label">既往病史：</label>
				<div class="controls">
					<form:input type="text" path="medicalHistory" class="span6" value="${childTijianRecord.medicalHistory}" placeholder="无"/>
				</div>
			</div>
			
			<div class="control-group span6 minWidth" data-line="line2">
				<label class="control-label"><font color="red">*</font> 体检日期：</label>
				<div class="controls">
					<input type="text" name="enrtYear" id="enrtYear" class="span6" value="${childTijianRecord.enrtYear}" />
				</div>
			</div>
		</div>
		
		<div class="row-fluid">
	        <div class="control-group span6 minWidth" data-line="line1">
				<label class="control-label">医院校医或盖章签字：</label>
				<div class="controls">
					<form:input type="text" path="hospitalDoctor" class="span6 required" value="${childTijianRecord.hospitalDoctor}"/>
				</div>
			</div>
			
		</div>
		
		<div class="form-actions">
			<shiro:hasPermission name="childtijianrecord:childTijianRecord:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>